package edu.zju.gis.cky.global;

import edu.zju.gis.cky.entity.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author Zhou Yuquan
 * @version 1.0, 2021-12-10
 */
@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(Exception.class)
    public Result<Object> serviceExceptionHandler(Exception e) {
        if (e.getMessage() == null || e.getMessage().equals("")) {
            return Result.failure();
        } else {
            return Result.failure(e.getMessage());
        }
    }

}
